package com.example.myapplication;

import android.os.Bundle;
import android.util.Log;
import androidx.appcompat.app.AppCompatActivity;
import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = "MainActivity";
    private SPListUtils spListUtils;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        spListUtils =new SPListUtils(this);
        List<User> list1 = new ArrayList<>();
        list1 = spListUtils.getChannleData();
        Log.i(TAG, "onCreate:---- "+list1);
        saveData();

    }

    private void saveData() {
        List<User> list = new ArrayList<>();
        spListUtils =new SPListUtils(this);
        for (int i = 0; i < 4; i++) {
            User user = new User();
            user.setName("张" + i);
            user.setId("100" + i);
            if (i % 2 == 0) {
                user.setSex("0");
            } else {
                user.setSex("1");
            }
            list.add(user);
        }

        spListUtils.saveChannleData(list);
        Log.i(TAG, "saveData: ---------"+list);
    }

    class User {
        private String name;
        private String id;
        private String sex;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getSex() {
            return sex;
        }

        public void setSex(String sex) {
            this.sex = sex;
        }
    }
}
